let line = echarts.init(document.getElementById('line'));
let option_line;

option_line = {
    title:{
        text: '每日新增历史趋势图'
    },
    tooltip: {
        trigger: 'axis'
    },
    legend: {
        orient: 'horizontal',
        left: 'center',
        top:'10%',
        selectedMode: 'multiple',
        data: ['治愈新增', '死亡新增', '确诊新增', '境外输入新增', '死亡率', '治愈率']
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    toolbox: {
        feature: {
            saveAsImage: {show: true},
            restore: {show: true}
        }
    },
    xAxis: {
        type: 'category',
        boundaryGap: false,
        data:[]
    },
    yAxis: {
        type:'value'
    },
    series: [
        {
            name: '治愈新增',
            type: 'line',
            data:[]
        },
        {
            name: '死亡新增',
            type: 'line',
            data:[]
        },
        {
            name: '确诊新增',
            type: 'line',
            data:[]
        },
        {
            name: '境外输入新增',
            type: 'line',
            data:[]
        },
        {
            name: '死亡率',
            type: 'line',
            data:[]
        },
        {
            name: '治愈率',
            type: 'line',
            data:[]
        }
    ]
};

line.setOption(option_line);

function getchinaAddHistory() {
    line.showLoading();
    $.ajax({
        type: 'get',
        url: '/getchinaAddHistory',
        data: {},
        success: function (cAddData) {
            line.hideLoading();
            //console.log(cAddData['res'][0]);
            option_line.xAxis.data = cAddData['res'][0][0];
            option_line.series[0].data = cAddData['res'][0][1];
            option_line.series[1].data = cAddData['res'][0][2];
            option_line.series[2].data = cAddData['res'][0][3];
            option_line.series[3].data = cAddData['res'][0][4];
            option_line.series[4].data = cAddData['res'][0][5];
            option_line.series[5].data = cAddData['res'][0][6];
            line.setOption(option_line);//用配置项配置（动词）echarts
        }, error: function () {
            console.log("这个接口挂了");
        }
    })
}

getchinaAddHistory();

window.onresize=function(){
   line.resize();
};